<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
	content="text/html; charset=windows-1255">
<title>Ajax Test!!!</title>
</head>
<body>

	<script language="javascript" type="text/javascript">
		//Browser Support Code
		function ajaxFunction() {
			var ajaxRequest;

			// The variable that makes Ajax possible! 
			try {
				// Opera 8.0+, Firefox, Safari 
				ajaxRequest = new XMLHttpRequest();
			} catch (e) {
				// Internet Explorer Browsers 
				try {
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try {
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
						// Something went wrong 
						alert("Your browser broke!");
						return false;
					}
				}
			}

			// Create a function that will receive data sent from the server 
			ajaxRequest.onreadystatechange = function() {
				if (ajaxRequest.readyState == 4) {
					var response = ajaxRequest.responseText;
					if (response.charAt(0) == '1') {
						document.getElementById("myP").innerHTML = response
								.substring(1, ajaxRequest.responseText.length);
					} else {
						alert("An error was retrieved!!!");
					}
				}
			};

			var url = "jspTest.jsp";
			var params = "errorP=myP";
			ajaxRequest.open("POST", url, true);

			//Send the proper header information along with the request
			ajaxRequest.setRequestHeader("Content-type",
					"application/x-www-form-urlencoded");
			ajaxRequest.setRequestHeader("Content-length", params.length);
			ajaxRequest.setRequestHeader("Connection", "close");

			ajaxRequest.send(params);
		}

		function timer() {
			document.getElementById('userName').value++;
			t = setTimeout("timer()", 1000);
		}
	</script>
	<form name='myForm'>
		<p id='myP'>
			Name: <input type='text' onChange="ajaxFunction();" name='username'
				id='userName' /> <br /> Time: <input type='text'
				onClick="timer();" name='time' />
		</p>
		<p id="errorP"></p>
	</form>

</body>
</html>